<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://xmlns.jcp.org/jsf/passthrough"
                xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core">
    <!--开始 写作-->
    <script>$('.left-siderbar-add-text').addClass('active');</script>
    <h:form p:role="form">
        <div class="col-sm-8">
            <h3>撰写文章</h3>
            <div class="form-group">
                <h:outputLabel for="title" value="文章标题"/><span class="text-danger"><h:message for="title"/></span>
                <h:inputText id="title" value="#{postBean.title}" styleClass="form-control"
                             required="true" p:placeholder="标题" p:required="true"/>
            </div>
            <div class="form-group">
                <h:outputLabel for="content" value="文章内容"/><span class="text-danger"><h:message for="content"/></span>
                <h:inputTextarea id="content" value="#{postBean.content}" styleClass="form-control"
                                 required="true" p:placeholder="内容" p:required="true"/>
            </div>
        </div>
        <div class="col-sm-4">
            <h3>选项</h3>
            <div class="form-group">
                <h:outputLabel for="category" value="分类"/>
                <h:selectOneMenu id="category" styleClass="form-control" value="#{postBean.categoryId}">
                    <f:selectItems value="#{categoryBean.allTextCategory}"/>
                </h:selectOneMenu>
            </div>
            <div class="check-box">
                <h:outputLabel>
                    <h:selectBooleanCheckbox id="allow-comment" value="#{postBean.allowComment}"/>
                    允许评论
                </h:outputLabel>
            </div>
            <div class="form-group">
                <c:choose>
                    <c:when test="#{postBean.id eq 0}">
                        <h:commandButton action="#{postBean.post(true)}" styleClass="btn btn-primary" value="立即发表"/>
                        <h:commandButton action="#{postBean.post(false)}" styleClass="btn" value="存为草稿"/>
                    </c:when>
                    <c:otherwise>
                        <input name="id" value="#{postBean.id}" type="hidden"/>
                        <h:commandButton action="#{postBean.update(true)}" styleClass="btn btn-primary" value="立即发表"/>
                        <h:commandButton action="#{postBean.update(false)}" styleClass="btn" value="存为草稿"/>
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
    </h:form>
    <!--结束 写作-->
</ui:composition>